{extend name="template/base" /}
{block name="nav"}{/block}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <input type="hidden" name="id" value="{$vo.id ?? ''}">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>店铺类型：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="hidden" name="types_first_id" value="{$vo.types_first_id ?? ''}">
                <input type="hidden" name="types_second_id" value="{$vo.types_second_id ?? ''}">
                <input type="hidden" name="types_third_id" value="{$vo.types_third_id ?? ''}">
                <span class="dropDown"> <a class="dropDown_A" data-toggle="dropdown" aria-haspopup="true"
                        aria-expanded="true">选择类型</a>
                    <ul class="dropDown-menu menu radius box-shadow">
                        {volist name="typeTree" id="first" empty="请先创建店铺类型"}
                        <li><a href="javascript:;">{$first.name}</a>
                            {if condition="!empty($first._child)"}
                            <ul class="dropDown-menu menu radius box-shadow">

                                {volist name="first._child" id="second"}
                                <li>
                                    <a href="javascript:;">{$second.name}</a>
                                    {if condition="!empty($second._child)"}
                                    <ul class="dropDown-menu menu radius box-shadow">
                                        {volist name="second._child" id="third"}
                                        <li><a
                                                href="javascript:selectType({$first.id},{$second.id},{$third.id},'{$first.name}/{$second.name}/{$third.name}');">{$third.name}</a>
                                        </li>
                                        {/volist}
                                    </ul>
                                    {/if}
                                </li>
                                {/volist}

                            </ul>
                            {/if}
                        </li>
                        {/volist}
                    </ul>
                </span>
                <input type="text" readonly class="input-text" value="{$vo.types_name?? ''}" id="sel-types"
                    placeholder="请点击左边按钮选择" datatype="*" nullmsg="请选择分类" style="width: 80%">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">店铺地址：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="hidden" name="province" value="{$vo.province ?? ''}">
                <input type="hidden" name="city" value="{$vo.city ?? ''}">
                <input type="hidden" name="area" value="{$vo.area ?? ''}">
                <span class="dropDown"> <a class="dropDown_A" data-toggle="dropdown" aria-haspopup="true"
                        aria-expanded="true">选择城市</a>
                    <ul class="dropDown-menu menu radius box-shadow">
                        {volist name="address" id="first"}
                        <li><a href="javascript:;">{$first.province_name}</a>
                            {if condition="!empty($first.city)"}
                            <ul class="dropDown-menu menu radius box-shadow">

                                {volist name="first.city" id="second"}
                                <li>
                                    <a href="javascript:;">{$second.city_name}</a>
                                    {if condition="!empty($second.area)"}
                                    <ul class="dropDown-menu menu radius box-shadow">
                                        {volist name="second.area" id="third"}
                                        <li><a
                                                href="javascript:selectAddress('{$first.province_name}','{$second.city_name}','{$third}','{$first.province_name}/{$second.city_name}/{$third}');">{$third}</a>
                                        </li>
                                        {/volist}
                                    </ul>
                                    {/if}
                                </li>
                                {/volist}

                            </ul>
                            {/if}
                        </li>
                        {/volist}
                    </ul>
                </span>
                <input type="text" readonly class="input-text" value="{$address_name?? ''}" id="sel-address"
                    placeholder="请点击左边按钮选择" style="width: 80%">

                <div>
                    <input type="text" class="input-text" value="{$vo.detailed_address ?? ''}" placeholder="详情地址"
                        name="detailed_address">
                </div>

                <!--<div class="col-sm-4">
                    <select name="province" class="select" >
                        <option value="0">选择省份</option>
                    </select>
                </div>
                <div class="col-sm-4">
                    <select name="city" class="select">
                        <option value="0">选择市</option>

                        <option value="gy">选项</option>

                    </select>
                </div>
                <div class="col-xs-4">
                    <select name="area" class="select">
                        <option value="area">选择区</option>

                        <option value="hx">选项</option>

                    </select>
                </div>-->
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">店铺名称：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$vo.name ?? ''}" placeholder="" name="name">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">店铺图片：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <div class="row cl">
                    <div>
                        <input type="text" readonly class="input-text" name="thumb[]" value="{$thumbs[0] ?? ''}"
                            id="upload" placeholder="请点击后面的上传按钮" style="width: 60%">
                        <button type="button" class="btn btn-primary radius"
                            onclick="layer_open('文件上传','{:\\think\\Url::build(\'Upload/index\', [\'id\' => \'upload\'])}')">上传</button>
                        <a onclick="$(this).attr('href', 'http://{$Request.host}/public'+$('#upload').val())"
                            type="button" href="" class="btn btn-success radius" data-lightbox="example-1">预览</a>
                        <br />
                    </div>
                    <div id="up-box">
                        {volist name="thumb" id="thumb" key="k"}
                        {if condition="$k!=1"}
                        <div style="margin-top: 5px">
                            <input type="text" readonly class="input-text" name="thumb[]" value="{$thumb ?? ''}"
                                id="upload{$k}" placeholder="请点击后面的上传按钮" datatype="*" nullmsg="请填写图片url"
                                style="width: 60%">
                            <button type="button" class="btn btn-primary radius"
                                onclick="layer_open('文件上传','/admin/upload/index/id/upload{$k}.html')">上传</button>
                            <a onclick="$(this).attr('href', 'http://{$Request.host}/public'+$('#upload{$k}').val())"
                                type="button" href="" class="btn btn-success radius" data-lightbox="example-1">预览</a>
                            <span style="float:right;" onclick="$(this).parent('div').remove()">删除</span>
                        </div>
                        {/if}
                        {/volist}
                    </div>

                    <div style="text-align: right" onclick="addUpImg()">添加</div>
                </div>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>联系电话：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="tel" class="input-text" value="{$vo.phone ?? ''}" placeholder="" name="phone" datatype="*"
                    nullmsg="请填写电话">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">邮箱：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="email" class="input-text" value="{$vo.email ?? ''}" placeholder="" name="email"
                    datatype="e" ignore="ignore" errormsg="邮箱格式错误">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>商户结账类型：</label>
            <div class="formControls col-xs-6 col-sm-6 skin-minimal">
                <div class="radio-box">
                    <input type="radio" name="body_type" id="body_type-0" value="mchid">
                    <label for="body_type-0">商户账号</label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="body_type" id="body_type-1" value="openid">
                    <label for="body_type-1">个人账号</label>
                </div>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>结算账号：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" value="{$vo.spoils_no ?? ''}" placeholder="" name="spoils_no"
                    ignore="ignore">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>结算提成（百分比）：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="number" class="input-text" value="{$vo.spoils_percent ?? ''}" placeholder="" min="1"
                    max="30" name="spoils_percent" ignore="ignore">
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>状态：</label>
            <div class="formControls col-xs-6 col-sm-6 skin-minimal">
                <div class="radio-box">
                    <input type="radio" name="status" id="status-0" value="1">
                    <label for="status-0">启用</label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="status" id="status-1" value="0">
                    <label for="status-1">禁用</label>
                </div>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <!--<div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">备注：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <textarea class="textarea" placeholder="" name="remark" onKeyUp="textarealength(this,100)">{$vo.remark ?? ''}</textarea>
                <p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>-->

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20"
                    onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script>
    $(function () {
        $("[name='status'][value='{$vo.status ?? '1'}']").attr("checked", true);
        $("[name='body_type'][value='{$vo.body_type ?? 'mchid'}']").attr("checked", true)

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret) {
                ajax_progress(ret);
            }
        });
    })
    function selectAddress(fid, sid, tid, str) {
        $('#sel-address').val(str);
        $('input[name=province]').val(fid);
        $('input[name=city]').val(sid);
        $('input[name=area]').val(tid);
    }
    function selectType(fid, sid, tid, str) {
        $('#sel-types').val(str);
        $('input[name=types_first_id]').val(fid);
        $('input[name=types_second_id]').val(sid);
        $('input[name=types_third_id]').val(tid);
    }
    let temp = 0;
    function addUpImg() {
        let upload = 'upload' + Math.round(Math.random() * 10000) + (temp++);
        let html = "<div style='margin-top: 5px'><input type=\"text\" readonly class=\"input-text\" name=\"thumb[]\" value=\"{$vo.thumb ?? ''}\" id=\"" + upload + "\" placeholder=\"请点击后面的上传按钮\" datatype=\"*\" nullmsg=\"请填写图片url\" style=\"width: 60%\">\n" +
            "                        <button type=\"button\" class=\"btn btn-primary radius\" onclick=\"layer_open('文件上传','/admin/upload/index/id/" + upload + ".html')\">上传</button>\n" +
            "                        <a onclick=\"$(this).attr('href', 'http://{$Request.host}/public'+$('#" + upload + "').val())\" type=\"button\" href=\"\" class=\"btn btn-success radius\" data-lightbox=\"example-1\">预览</a>\n" +
            "                        <span style=\"float:right;\" onclick=\"$(this).parent('div').remove()\">删除</span></div>";
        $('#up-box').append(html);
    }
</script>
{/block}